package com.yl.module.property.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yl.module.property.mapper.PropertyBimUeInfoMapper;
import com.yl.module.property.service.PropertyBimUeInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.yl.module.property.domain.vo.PropertyBimUeInfoVO;
import com.yl.module.property.domain.dto.PropertyBimUeInfoDTO;
import com.yl.module.property.domain.PropertyBimUeInfo;
import cn.hutool.core.bean.BeanUtil;
import java.util.List;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;

/**
 * 资产bim、ue初始化信息表 Service实现类
 * @author liangjian
 * @date 2024-10-27 18:56:47
 */
@Service
@Slf4j
public class PropertyBimUeInfoServiceImpl extends ServiceImpl<PropertyBimUeInfoMapper, PropertyBimUeInfo> implements PropertyBimUeInfoService {

	@Autowired
	PropertyBimUeInfoMapper propertyBimUeInfoMapper;

   /**
	 * 查询所有
	 */
	@Override
	public List<PropertyBimUeInfoVO> getAll(){
		List<PropertyBimUeInfoVO> result = propertyBimUeInfoMapper.getAll();
		return result;
	}

	/**
     * 分页查询
     */
	@Override
    public Page<PropertyBimUeInfo> getPage(PropertyBimUeInfoDTO dto){
		//创建分页对象
		Page<PropertyBimUeInfo> page = new Page(dto.getPageNum(), dto.getPageSize());
		//dto查询条件转分页条件
		LambdaQueryWrapper<PropertyBimUeInfo> lqw = new LambdaQueryWrapper<>();
		Page<PropertyBimUeInfo> result = propertyBimUeInfoMapper.selectPage(page, lqw);
		return result;
	}

	/**
	 * 通过主键查询
	 */
	@Override
	public PropertyBimUeInfoVO getByKey(Integer id){
		PropertyBimUeInfo entity = super.getById(id);
		PropertyBimUeInfoVO result = BeanUtil.copyProperties(entity, PropertyBimUeInfoVO.class);
        return result;
    }

	/**
	 * 添加
	 */
	@Override
	public Integer add(PropertyBimUeInfoDTO dto){
		PropertyBimUeInfo propertyBimUeInfo = BeanUtil.copyProperties(dto, PropertyBimUeInfo.class);
		this.save(propertyBimUeInfo);
		return propertyBimUeInfo.getId();
	}

	/**
	 * 通过主键修改
	 */
	@Override
	public void upd(PropertyBimUeInfoDTO dto){
		PropertyBimUeInfo propertyBimUeInfo = BeanUtil.copyProperties(dto, PropertyBimUeInfo.class);
	    this.updateById(propertyBimUeInfo);
	}

}



